package com.mall.service;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mall.dao.mapper.CommDetailedMapper;
import com.mall.model.CommDetailed;
import com.mall.model.CommDetailedExample;

@Service
public class CommDetailedService {
	@Autowired
	private CommDetailedMapper commDetailedMapper;
	/**
	 * 添加商品明细
	 *
	 *@dagewang 2017年8月15日
	 */
	public int save(CommDetailed commDetailed, Integer id) throws Exception{
		  Date date =new Date();
		  commDetailed.setCdate(date);
		  commDetailed.setCommodityid(id);
		  commDetailed.setId(null);
			  int insert = commDetailedMapper.insert(commDetailed);
		return insert;
	}
	/**
	 * 是否有商品详情
	 *
	 *@dagewang 2017年8月22日
	 */
	public boolean isDetailed(Integer id){
		
		return false;
		
	}
	/**
	 * 根据商品id获取商品详细信息
	 *
	 *@dagewang 2017年8月29日
	 */
	public CommDetailed get(Integer id) throws Exception{
		CommDetailed selectByCommId = commDetailedMapper.selectByCommId(id);
		return selectByCommId;
	}
	public CommDetailedMapper getCommDetailedMapper() {
		return commDetailedMapper;
	}
	public void setCommDetailedMapper(CommDetailedMapper commDetailedMapper) {
		this.commDetailedMapper = commDetailedMapper;
	}
	/**
	 * 更新商品详情
	 *@dagewang 2017年9月7日
	 */
	public int update(CommDetailed commDetailed) throws Exception{
					commDetailed.setUdate(new Date());
		
				return commDetailedMapper.updateByPrimaryKeySelective(commDetailed);
	}
	
	

}
